{% extends 'base.html' %}

{% block page-content %}




            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">部门管理</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">



                <div class="col-lg-12">


                    <div class="panel panel-default">
                        <div class="panel-heading">
                            部门管理
                        </div>
                        <div  class="panel-body">

                     <div class="col-lg-12">
                    <p>
                        <a  href="{% url 'dept_add' %}"><button class="btn btn-primary " type="button">添加部门</button></a>
                    </p>
                </div>
                    <div class="col-lg-8">
                    <div class="panel panel-default">

                        <div class="panel-heading">
                            基本信息
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">

                                <table class="table table-hover">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>部门</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                       {% for c in Deptlist%}
                                        <tr>
                                            <td>{{c.id}}</td>
                                            <td>{{c.name}}</td>
                                              <td class="center">

                                                <a class="btn btn-xs btn-info" href="/account/dept/edit/{{c.id}}">编辑</a>
                                                  <button class="btn btn-xs btn-danger" data-toggle="modal"  onclick="clickurl('{{c.id}}')"  data-target="#myModal" >删除</button>
                                            </td>
                                        </tr>
                                    {%endfor%}

                                    </tbody>
                                </table>

                                 <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                                   aria-labelledby="myModalLabel" aria-hidden="true">
                                   <div class="modal-dialog">
                                      <div class="modal-content">
                                         <div class="modal-header">
                                            <button type="button" class="close"
                                               data-dismiss="modal" aria-hidden="true">
                                                  &times;
                                            </button>
                                            <h4 class="modal-title" id="myModalLabel">
                                               删除提醒
                                            </h4>
                                         </div>
                                         <div class="modal-body">
                                            系统提示:您是否确认删除这条记录!!!!
                                         </div>
                                         <div class="modal-footer">
                                            <button type="button" class="btn btn-default"
                                               data-dismiss="modal">关闭
                                            </button>
                                            <a class="btn btn-primary" id="postdel" > 删除</a>
                                         </div>

                                      </div><!-- /.modal-content -->
                                </div><!-- /.modal -->

                            </div>

                             <div class="modal fade" id="myModal2" tabindex="-1" role="dialog"   aria-labelledby="myModalLabel">
                              <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                  <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel">系统提示</h4>
                                  </div>
                                  <div class="modal-body">
                                         <p id="getdata">ddddddd</p>
                                  </div>
                                <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                        <a class="btn btn-primary" href="/account/dept/list/">确定</a>
                                    </div>
                                 </div>

                                </div>
                              </div>
                            </div>


                             <script>
                               function clickurl(url){
                                    $("#postdel").click(function() {
                                        $.get("/account/dept/del/"+url,
                                                 function (data) {
                                                    $('#myModal').modal('hide')
                                                    $("#getdata").html(data);
                                                    $('#myModal2').modal('show');
                                                });
                                    });
                                }
                          </script>

                        </div>
                        <!-- /.panel-body -->
               
                    </div>
                    <!-- /.panel -->
                </div>




            </div>
            <!-- /.row -->

      {% endblock %}